<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common-app/taglibs.jsp"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>参与人员详细信息</title>
<%@ include file="/common/meta.jsp"%>
<script type="text/javascript" src="${res}/js/proposal/irisPrpPrepare.js"></script>
<script type="text/javascript" src="${res}/js/validate/irisvalidator.js"></script>
<script type="text/javascript" src="${res}/js/autodisckey/autodisckey.js"></script>

<style type="text/css">
	.input_width { width:130px }
	.select_width { width:143px }
	.table_td td {border:0}
	.long_input{ width:642px }
    .selectWidth4{width:624px;}
</style>
<script type="text/javascript">
var type = "${param.type}";
var parentTable = parent.$("#"+"${param.parentTab}");	//父页面的表格
var selectRadio = $();									//父页面选中的单选框
var selectTr = $();										//父页面选中的行

if(type=="edit") {
	selectRadio = parentTable.find(":radio:checked");
	selectTr = selectRadio.parents("tr");
}

$(function(){
	$("#fragment-tab1 :text,#fragment-tab1 [type='date']").addClass("input_width");
	$("#fragment-tab1 select").addClass("select_width");
	
	$("#fragment-tab1 tr:even").addClass("li_2");
	$("#fragment-tab1 tr:odd").addClass("li_1");

	
	if(type=="edit"){
		
		$("input:not(:radio:checkbox:button),textarea").each(function(){

			var id=$(this).attr("name");
			if(id==null || id=="")
				return true;
			
			var parentObj=selectTr.find("[name$='/"+id+"']");
			var value="";
			if(parentObj.is("span"))
				value=parentObj.text();
			else
				value=parentObj.val();
			//if($(this).is("input"))//初始化input框 不包括radio
				$(this).val(value);
		});
		
		$(":radio").each(function(){//初始化radio框
			var name=$(this).attr("name");
		
			
			var value=$("[name='"+name+"_value']").val();
			if($(this).val()==value)
				$(this).attr("checked",true);
			
		});
		$(":checkbox").each(function(){//初始化radio框
			var name=$(this).attr("name");
		
			
			var value=","+$("[name='"+name+"_value']").val()+",";
			var temp_value=","+$(this).val()+",";
			if(value.indexOf(temp_value)>-1)
				$(this).attr("checked",true);
			
		});
		
	} 
	
	function changValue(){
		$("#project_start_date").val($("#start_date").val());
		$("#project_end_date").val($("#end_date").val());
	}
	
	
	function savePsn(){
		//填写检查接口\
		changValue();
		validate($("#fragment-tab1"),"");
		
		var international_stand =parseFloat($("#international_stand").val());
		var country_stand =parseFloat($("#country_stand").val());
		var industry_stand =parseFloat($("#industry_stand").val());
		var expect_stand =parseFloat($("#expect_stand").val());
		if(expect_stand <(international_stand + country_stand+industry_stand)){
			irisValaddMsg("预期形成标准不能小于国际标准、国家标准与行业标准之和");
		}
		
		
		if(!valResult()){
			irisValShowMsg($("#savePsn"));
			return false;
		}
		
		
		beforesave();
		
		//添加新行
		if(type=="add") {
			addNewRowDeal(parentTable);
//			parent.countPsnNum('zh_persons,researchs','psncnt_total');
		}
		
		$("input:not(:radio:button),textarea").each(function(){
			
			var id=$(this).attr("name");
			var parentObj=null;
			
			if(id==null || id=="")
				return true;
			
			//获得父页面的对象
			if(type=="add"){
				parentObj=parentTable.find("tr:last-child").find("[name$='/"+id+"']");
			}else if(type=="edit"){
				parentObj=selectTr.find("[name$='/"+id+"']");
				
			}

			if(parentObj!=null){
				if(parentObj.is("span")){
					parentObj.text($(this).val());	//将值写回父页面
				}
				else{
					parentObj.val($(this).val());
				}
			}
			
		});
		
		if(type=="add"){
			parentTable.find("tr:last :radio").attr("checked",true);
			if("${param.parentTab}"=="zh_persons")
				parent.setSubmitPsn();
		}		
		
		$(".wBox_popup").hide();
		if(confirm("保存成功，是否返回申请书页面")){
			parent.tb_remove();
		}
			
		else if(type=="add"){
			type = "edit";
			selectRadio = parentTable.find(":radio:checked");	//父页面选中的单选框
			selectTr = selectRadio.parents("tr");				//父页面选中的行
		}
		
		parent.totaltwo();
		
	}
	
	$("#savePsn").click(function(){
		setTimeout(savePsn,100);
	});
	
	function beforesave(){
		$("textarea").each(function(){
    		var val=$(this).val();
    		//alert(val.indexOf(" ")+"=="+val.lastIndexOf(" "));
    		val = val.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br/>").replace(/\s/g,"&nbsp;").replace(/"/g,"&quot;");
    		//alert("input[nam*="+$(this).attr('name')+"_hidden]");
    	
    		$("input[name='"+$(this).attr('name')+"_hidden']").val(val);
    			
    		//$(this).html(val);
    	});
	}
	
	
});
function initControlValue(objId){
	
	if(typeof(objId)=="object"){
		if($(objId).find("input").attr("type")=="checkbox"){
			
			var name="technical_field";
			var values =""; 
			var names ="";
			
			$(objId).parents("td").find('input:checked').each(function(){ 
				values=values+","+$(this).val();
				names=names+","+$(this).attr("label");
				name=$(this).attr("name");
			}); 
			
			values = values.substring(1);
			names = names.substring(1);
			$("input[name$='"+name+"_value'][type='hidden']").val(values);
			$("input[name$='"+name+"_name']").val(names);
			return;
		}

		if($(objId).find("input").attr("type")=="radio"){
			var name=$(objId).find("input").attr("name");
			$("input[name$='"+name+"_value'][type='hidden']").val($(objId).find("input").val());
			$("input[name$='"+name+"_name']").val($(objId).find("input").attr("label"));
	    	return;
		}
		
	}
	
	
}

function loadAjaxSelect(selectId,url,params,varParm){
	$.ajax( {
		url : url,
		type : 'post',
		dataType:'json',
		data : params,
		success : function(data) {
			
			for(var i=0;i<data.length;i++){
				var value=data[i].id;
				var text=data[i].name;		
				$("#"+selectId).append("<option value='"+value+"'>"+text+"</option>");
				

			}
			if(type=="edit"){//如果是修改，才需要初始化select框的值
				var selectValue=$("[name='"+selectId+"_value']").val();
				$("#"+selectId+" option").each(function(i,obj){
					if($(obj).val()==selectValue){
						setTimeout(function() {
							$(obj).attr("selected",true);
						}, 1);
					}
				});
			}
			
			setDegree();	
		}
	});
	}
</script>
</head>
<body>

	<div id="tabnav">
		<ul>
			<li class="down" id="tab1" onclick="changeTab(this.id)">
					<a href="###"><span>成果信息</span></a>
			</li>
		</ul>
	</div>

<div class="tab_box" id="fragment-tab1">
		<table id="basicAchieveInfo" border="0" cellspacing="0" cellpadding="0" class="table01 t_css" >
	<col style="width:20%"/>
	<col style="width:20%"/>
	<col style="width:20%"/>
	<col style="width:20%"/>
	<col style="width:20%"/>
	<tr>
		<td align="right"><span class="color_red">*</span>技术合同项目名称：</td>
		<td colspan="4">
			<input id="project_name" name="project_name" label="技术合同项目名称" type="text" required 
			class="input_css required maxlength:50"  style="width:90%;" maxlength="50" value=""/>
		</td>
	</tr>
	<tr>
		<td align="right"><span class="color_red">*</span>合同开始时间：</td>
		<td>
			<cpt:date id="start_date" name="start_date" value="" className=" required date   dateCompare:end_date " label="合作开始时间" ></cpt:date>
		</td>
		<td align="right"><span class="color_red">*</span>合同结束时间：</td>
		<td>
			<cpt:date id="end_date" name="end_date" value="" className=" required date" label="合作结束时间" ></cpt:date> 
		</td>
		<td></td>
	</tr>
	<tr>
		<td align="right"><span class="color_red">*</span>技术合同交易类别：</td>
		<td colspan="4">
			<cpt:checkbox key="transaction_type" name="transaction_type" repeatColumn="3" tagType="radio" onClick="initControlValue" style="border: 0px; padding: 0px; margin: 0px;" ></cpt:checkbox> 
            <input type="hidden" name="transaction_type_value" id="transaction_type" value="" class="required" label="技术合同交易类别"/>
            <input type="hidden" name="transaction_type_name" id="transaction_type_name" value="" />
		</td> 
	</tr>
	<tr>
		<td align="right"><span class="color_red">*</span>技术成果所属领域：</td>
		<td colspan="4">
			<cpt:checkbox key="technical_field_1" name="technical_field" repeatColumn="5"  onClick="initControlValue" style="border: 0px; padding: 0px; margin: 0px;" ></cpt:checkbox>
            <input type="hidden" name="technical_field_value" id="technical_field" value="" class="required" label="技术成果所属领域"/>
            <input type="hidden" name="technical_field_name" id="technical_field_name" value="" />
		</td>
	</tr>
	<tr>
		<td align="right"><span class="color_red">*</span>技术成果水平：</td>
		<td colspan="4">
			<cpt:checkbox key="technical_level_1" name="technical_level" repeatColumn="4" tagType="radio" onClick="initControlValue" style="border: 0px; padding: 0px; margin: 0px;" ></cpt:checkbox>
            <input type="hidden" name="technical_level_value" id="technical_level" value="" class="required" label="技术成果水平"/>
            <input type="hidden" name="technical_level_name" id="technical_level_name" value="" />
		</td>
	</tr>
	<tr>
		<td align="right"><span class="color_red">*</span>卖方单位名称：</td>
		<td colspan="4">
			<input id="seller_dept" name="seller_dept" label="卖方单位名称" type="text" required 
			class="input_css required maxlength:100"  style="width:90%;" maxlength="100" value=""/>
		</td>
	</tr>
	<tr>
		<td align="right"><span class="color_red">*</span>卖方所在地：</td>
		<td colspan="4">
			<input id="seller_address" name="seller_address" label="卖方所在地" type="text" required 
			class="input_css required maxlength:100"  style="width:90%;" maxlength="100" value=""/>
			
		</td>
	</tr>
	<tr>
		<td align="right"><span class="color_red">*</span>卖方单位性质：</td>
		<td colspan="4">
		<cpt:checkbox key="seller_type" name="seller_type" repeatColumn="5" tagType="radio" onClick="initControlValue" style="border: 0px; padding: 0px; margin: 0px;" ></cpt:checkbox>
            <input type="hidden" name="seller_type_value" id="seller_type_value" value="" class="required" label="卖方单位性质"/>
            <input type="hidden" name="seller_type_name" id="seller_type_name" value="" />
		</td>
	</tr>
	<tr>
		<td align="right" rowspan="2"><span class="color_red">*</span>技术合同总金额：</td>
		<td rowspan="2">
			<input id="contract_amount" name="contract_amount" label="技术合同总金额" type="text" 
			onfocus="InitInput.setNumber(this,9,4,2);" required class="input_css required maxlength:50"  style="text-align:right" maxlength="50" 
			value=""/>万元
		</td>
		<td align="right" colspan="2"><span class="color_red">*</span>已支付金额：</td>
		<td>
			<input id="payed_amount" name="payed_amount" label="技术合同总金额" type="text" 
			onfocus="InitInput.setNumber(this,9,4,2);" required class="input_css required maxlength:50"  style="text-align:right" maxlength="50" 
			value=""/>万元
		</td>
	</tr>
	<tr>
		<td align="right" colspan="2"><span class="color_red">*</span>其中：${param.year-1}年支付金额（以发票为准）：</td>
		<td>
			<input id="year_amount" name="year_amount" label="${param.year-1}年支付金额（以发票为准）" type="text" 
			onfocus="InitInput.setNumber(this,9,4,2);" required class="input_css required maxlength:50"  style="text-align:right" maxlength="50" 
			value=""/>万元
		</td>
	</tr>
		
	<tr>
		<td align="right"><span class="color_red">*</span>引进技术开发计划总投入（万元）：</td>
		<td>
			<input id="imported_amount" name="imported_amount" label="引进技术开发计划总投入" type="text" 
			onfocus="InitInput.setNumber(this,9,4,2);" required class="input_css required maxlength:50"  style="text-align:right" maxlength="50" 
			value=""/>
		</td>
		<td align="right" colspan="2"><span class="color_red">*</span>其中：已完成研发投入（万元）：</td>
		<td>
			<input id="research_amount" name="research_amount" label="已完成研发投入（万元）" type="text" 
			onfocus="InitInput.setNumber(this,9,4,2);" required class="input_css required maxlength:50"  style="text-align:right" maxlength="50" 
			value=""/>
		</td>
	</tr>
	<tr>
		<td align="right" rowspan="3"><span class="color_red">*</span>预期形成标准（个）：</td>
		<td align="left" rowspan="3">
			<input id="expect_stand" name="expect_stand" label="预期形成标准" type="text" 
			onfocus="InitInput.setNumber(this,9,0,0);" required class="input_css required maxlength:50"  style="text-align:right" maxlength="50" 
			value=""/>
		</td>
		<td align="right" rowspan="3">其中：</td>
		<td align="right"><span class="color_red">*</span>国际标准（个）：</td>
		<td>
			<input id="international_stand" name="international_stand" label="国际标准" type="text" 
			onfocus="InitInput.setNumber(this,9,0,0);" required class="input_css required maxlength:50"  style="text-align:right" maxlength="50" 
			value=""/>
			
		</td>
	</tr>
	<tr>
		<td align="right"><span class="color_red">*</span>国家标准（个）：</td>
		<td>
			<input id="country_stand" name="country_stand" label="国家标准" type="text" 
			onfocus="InitInput.setNumber(this,9,0,0);" required class="input_css required maxlength:50"  style="text-align:right" maxlength="50" 
			value=""/>
			
		</td>
	</tr>
	<tr>
		<td align="right"><span class="color_red">*</span>行业标准（个）：</td>
		<td>
			<input id="industry_stand" name="industry_stand" label="行业标准" type="text" 
			onfocus="InitInput.setNumber(this,9,0,0);" required class="input_css required maxlength:50"  style="text-align:right" maxlength="50" 
			value=""/>
			
		</td>
	</tr>
	
	<tr>
		<td align="right"><span class="color_red">*</span>预期申请知识产权（项）：</td>
		<td>
			<input id="intellectual_property" name="intellectual_property" label="预期申请知识产权" type="text" 
			onfocus="InitInput.setNumber(this,9,0,0);" required class="input_css required maxlength:50"  style="text-align:right" maxlength="50" 
			value=""/>
		</td>
		<td align="right" colspan="2"><span class="color_red">*</span>其中：发明专利（项）：</td>
		<td>
			<input id="invention_patent" name="invention_patent" label="发明专利" type="text" 
			onfocus="InitInput.setNumber(this,9,0,0);" required class="input_css required maxlength:50"  style="text-align:right" maxlength="50" 
			value=""/>
		</td>
	</tr>
	<tr>
		<td align="right"><span class="color_red">*</span>技术成果转化和产业化情况（限500字）：</td>
          <td colspan="4">
		  <textarea rows="8" style="width:98%;"  class="input_textarea required maxlength:500"  id="transform_status" name="transform_status" label="技术成果转化和产业化情况"></textarea>
		  <input type="hidden"  name="transform_status_hidden" id="transform_status_hidden" value="">
		  </td>
      </tr>
</table>
	</div>

	<table width="100%" align="center">
		<tr>
			<td><input type="button"  class="button_01 notdisabled" id="savePsn" value="保存">
				&nbsp;<input type="button" id="cancel" class="button_01 notdisabled" value="取消" onclick="parent.tb_remove();">
			</td>
		</tr>
	</table>
	<br />
</body>
</html>